﻿using J.Status.Application.Command.LodgingCommand;
using J.StatusModel;
using J.StatusModel.Dto;
using MediatR;
using StatusService;

namespace J.Status.Application.Handler.LodgingHandler
{
    public class LodgingFillHandler : IRequestHandler<LodgingFillCommand, List<LodgingAllDto>>
    {
        private readonly ILodgingDtoService lodgingDtoService;
        public LodgingFillHandler(ILodgingDtoService lodgingDtoService)
        {
            this.lodgingDtoService = lodgingDtoService;
        }

        public async Task<List<LodgingAllDto>> Handle(LodgingFillCommand request, CancellationToken cancellationToken)
        {
            if (request.OrderState == OrderState.待入住||request.OrderState==OrderState.超时未入住|| request.OrderState == OrderState.已取消)
            {
                return await lodgingDtoService.LodgingOneData(request.Id,request.OrderState);
            }
            else
            {
                return await lodgingDtoService.LodgingOneData2(request.Id, request.OrderState);
            }
        }
    }
}
